# -*- coding: utf-8 -*-

# Blueprint plugin for Pylons
# João Moreno 2008
# GPLv3

from paste.script.command import Command, BadCommand
from paste.script.filemaker import FileOp
import os, sys, shutil

class BluePrint(Command):
    
    max_args = 0
    min_args = 0
    
    usage = 'blueprint'
    summary = 'Create the BluePrint folder structure inside the public/css folder'
    group_name = 'pylons'
    
    parser = Command.standard_parser(verbose=True)
    
    def command(self):
        file_op = FileOp()
        src = os.path.join(os.path.dirname(__file__), "css")
        dest = os.path.join(file_op.find_dir('public', True)[1], "css")
        msg = file_op.shorten(os.path.join(dest, "blueprint"))
        try:
            shutil.copytree(src, dest)
            print "Blueprint CSS files were copied to %s." % msg
        except OSError, e:
            try:
                src = os.path.join(src, "blueprint")
                dest = os.path.join(dest, "blueprint")
                shutil.copytree(src, dest)
                print "Blueprint CSS files were copied to %s." % msg
            except OSError, e:
                print "It seems that Blueprint already exists on %s." % msg
